import React, { createContext, useContext, useState } from "react";

const GlobalContext = createContext({})

export const GlobalProvider = ({ children }) => {
    const [user, setUser] = useState()
const [theme, setTheme] = useState('light')
    // 全局状态
    const value = {
        user,
        setUser,
        theme,
        setTheme
    }
    return <GlobalContext.Provider value={value}>
        {children}
    </GlobalContext.Provider>
}

export const useGlobalContext = () => {
    return useContext(GlobalContext)
}